#define MOISTURE_PIN A1 // Analog pin connected to the sensor void setup() { Serial.begin(9600); // Initialize Serial communication pinMode(MOISTURE_PIN, INPUT); // Set moisture sensor pin as INPUT } void loop() { int moistureValue = analogRead(MOISTURE_PIN); // Read moisture level if (moistureValue > 500) { Serial.println("Wet condition"); } else { Serial.println("Dry condition"); } Serial.print("Moisture: "); Serial.println(moistureValue); delay(1000); // Wait 1 second before next reading }